enyo.kind({
    name: "MyApps.WeekPromotion",
    kind: enyo.VFlexBox,
    events: {
        onBack: "",
    },
    components: [    /**
     * service
     */
    {
        name: "getData",
        kind: "WebService",
        url: "http://query.yahooapis.com/v1/public/yql?q=select * from xml where url= 'http://www.golfplus.fr/xml/xml_iphone_PROMO.xml' &format=json&callback=",
        onSuccess: "gotData",
        onFailure: "gotDataFailure"
    },    /**
     * Layout
     */
    {
        name: "pane",
        kind: "Pane",
        flex: 1,
        components: [{
            kind: "VFlexBox",
            flex: 1,
            
            components: [{
            
                kind: "PageHeader",
                className: "enyo-header-dark",
                components: [{
                    kind: "IconButton",
                    onclick: "doBack",
                    icon: "images/menu-icon-back.png",
                    className: "enyo-button-dark"
                }, {
                    kind: "VFlexBox",
                    flex: 1,
                    align: "center",
                    components: [{
                        content: "Promo de la semaine"
                    }, ]
                }, {
                    kind: "IconButton",
                    onclick: "showPromotionLinkWeb",
                    icon: "images/web.png",
                    className: "enyo-button-dark",
                
                }, ]
            }, {
                kind: "VFlexBox",
                flex: 1,
                align: "center",
                pack: "center",
                components: [{
                    name: "promotionImage",
                    kind: "Image",
                    onclick: "showPromotionLinkWeb"
                }]
            }]
        
        }, {
            name: "promotionlinkweb",
            kind: "MyApps.Web",
            onBack: "goBack",
			lazy:true,
        
        }],
    }],
    create: function(){
        this.inherited(arguments);
        this.link;
        this.$.getData.call();
    },
    gotData: function(inSender, inResponse){
        this.pictureurl = inResponse.query.results.promo_semaine.img;
        this.link = inResponse.query.results.promo_semaine.link;
        this.$.promotionImage.setSrc(this.pictureurl);
        console.log("got Data");
    },
    
    
    gotDataFailure: function(inSender, inResponse){
        console.log("got failure from getData");
    },
    
    goBack: function(inSender, inEvent){
        this.$.pane.back(inEvent);
    },
    showPromotionLinkWeb: function(){
        this.$.pane.selectViewByName("promotionlinkweb");
        this.$.promotionlinkweb.setUrl(this.link);
		this.$.promotionlinkweb.setTitle("Promo de la semaine");
    }
    
});



